import { approvedColumns } from './approved.config.js'
import search from './../search/search.js';
import { fetchList } from '@/api/shop/info.js'
export default {
    name: "approved",
    mixins: [search],
    data() {
        return {
            approvedColumns,
            loading: false,
            loadData: [/* {
                id: 1,
                fs: 'http://img3.imgtn.bdimg.com/it/u=1940916231,627575868&fm=26&gp=0.jpg'
            } */],
            page: {
                current: 1,
                total: 0,
                size: 10
            },
            showSizeChanger: true,
            showTotal: total => `共有${total}条`,
            selectedRowKeys: [],  //选中的数组
            selectedRows: [],
            number: 0,
            btn: [
                // {
                //     title: "发布到门店",
                //     isShow: true
                // },
            ],
            xsleList:[
                {
                    label:"全部业务",
                    value:"01",
                },
                {
                    label:"商超",
                    value:"02",
                },
                {
                    label:"洗衣",
                    value:"03",
                },
                {
                    label:"家政",
                    value:"04",
                },
                {
                    label:"咖吧",
                    value:"05",
                }
            ]
        }
    },
    filters: {
        glstatus: data => {
            switch (data) {
                case "01":
                    return "营业中";
                case "02":
                    return "停业";
                default:
            }
        },
        glbusinessType: data => {
            switch (data) {
                case "01":
                    return "全部业务";
                case "02":
                    return "商超";
                case "03":
                    return "洗衣";
                case "04":
                    return "家政";
                case "05":
                    return "咖吧";
                default:
            }
        },
        glshopType: data => {
            switch (data) {
                case "01":
                    return "平台";
                case "02":
                    return "分公司";
                case "03":
                    return "代理商";
                default:
            }
        },
    },
    methods: {
        getList(searchForm, page) {
            if (searchForm) {
                console.log(searchForm)
            }
            if (page) {
                this.pagination.current = page
            }
            fetchList(Object.assign({ status: '' }, searchForm ? searchForm : {}, this.pagination,)).then(val => {
                let data = val.data
                this.page = {
                    current: data.current,
                    total: data.total,
                    size: data.size,
                }
                this.loadData = data.records
                this.loadData.forEach(item => {
                    item.businessType3 = []
                    item.businessType2 = item.businessType.split(',')
                    item.businessType2.forEach(i => {
                        this.xsleList.forEach(m => {
                            if (i == m.value) {
                                item.businessType3.push(m.label)

                            }
                        })
                    })
                    item.businessType1 = item.businessType3.join(',')
                })
                this.$emit("trigger")
            })
            /* setTimeout(() => {
                this.pagination.total = 200
            }, 500) */
        },
        onShowSizeChange(current, size) {
            console.log(current, size)
            this.page.current = current
            this.page.size = size
            this.getList()
        },
        onSelectChange(selectedRowKeys, selectedRows) {
            this.selectedRowKeys = selectedRowKeys
            this.selectedRows = selectedRows;
            this.number = this.selectedRows.length
        },
        // 清空选中项
        clearSelection() {
            this.selectedRowKeys = []
            this.number = 0
        },
        handler(index) {
            if (index === "0") {
                this.publishToStore()
            } else if (index == 1) {
                this.onSale()
            } else if (index == 2) {
                this.stopSale()
            } else if (index == 3) {
                this.delete()
            } else if (index == 4) {
                this.export()
            }
        },
        // 发布到门店
        publishToStore() {

        },
        // 在售
        onSale() {

        },
        // 停售
        stopSale() {

        },
        // 删除
        delete() {
            console.log(123321)
        },
        // 导出
        export() {

        },
        edit() { },
        dpedit(row) {
            console.log(row)
            this.$router.push({
                path: '/shop/info/addShop',
                query: row
            })
        },
        view(row) {
            this.$router.push({
                path: '/shop/info/addShop',
                query: row
            })
        }
    }

} 